package view.WelcomePanels.SubPanels;

import domain.WelcomeController;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JPanel;
import view.HelperClasses.ImageButton;
import view.WelcomeFrame;

/**
 *
 * @author Joachim
 */
public class MinimizeCloseButtonsPanel extends JPanel {

    private WelcomeFrame frame;
    
    public MinimizeCloseButtonsPanel(WelcomeFrame frame) {
        this.frame = frame;
        initPanel();
        addComponents();
    }
    
    private void initPanel() {
        this.setOpaque(false);
        this.setPreferredSize(new Dimension(75,50));
        this.setLayout(new FlowLayout(FlowLayout.TRAILING,0,0));
    }
    
    private void addComponents() {
        JButton btnMinimize = new ImageButton(getClass().getResource("/resources/minimize.png"));
        btnMinimize.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                frame.setState(Frame.ICONIFIED);
            }
        });
        this.add(btnMinimize);
        JButton btnClose = new ImageButton(getClass().getResource("/resources/close.png"));
        btnClose.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                System.exit(0);
            }
        });
        this.add(btnClose);
    }
    
}
